import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:wangziyi_app/constans/constans.dart';
import 'package:wangziyi_app/constans/text_stype.dart';
import 'package:wangziyi_app/main.dart';
import 'package:wangziyi_app/pages/personal_information.dart';
import 'package:wangziyi_app/pages/setting_page.dart';
import 'package:wangziyi_app/widgets/BottomClipper.dart';
import 'package:wangziyi_app/widgets/my_painter.dart';

class PersonalPage extends StatefulWidget {

  @override
  _PersonalPageState createState() => _PersonalPageState();
}

class _PersonalPageState extends State<PersonalPage> {
  int appThemeColorIndex;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    sharedPreferences.then((value) {
      appThemeColorIndex=  value.get("themeColor");
    });
  }
  @override
  Widget build(BuildContext context) {

    List myList = [
      '收藏夹',
      '关注店铺',
      '足迹',
      '红包卡券',
    ];
    List myListNumber = [
      '0',
      '0',
      '0',
      '0',
    ];
    List titles = ['会员中心', '积分', '红包省钱卡', '红包签到'];
    List orderIcon = [Icons.account_balance_wallet_rounded,
      Icons.insert_drive_file,
      Icons.shopping_cart,
      Icons.comment,
      Icons.attach_money,];
    List ordertitle = ['待付款', '待发货', '待收货', '待评论', '退款/售后'];
    List walletMoneys = ['0.00', '0', '0.0', '0.00', '0'];
    List walletTitles = ['余额', '津贴', '豆豆', '礼品卡', '银行卡'];

    return Scaffold(
      backgroundColor: Color(0xfff7f7f7),
        appBar:AppBar(toolbarHeight: 0,elevation: 0,),
        body: Container(
      height: double.infinity,//自适应高度
      child: Stack(
        children: <Widget>[

          Container(
            height: 220,
            color: Colors.transparent,
            child: ClipPath(
              clipper: BottomClipper(),
              child: Container(
                  color: colorModel.appThemeColor,
                  child: Column(
                    children: [
                      SizedBox(
                        height: 10,
                      ),
                     GestureDetector(child:ListTile(
                       leading: Container(
                         child: ClipOval(
                           //圆形

                           child: Image.asset(
                             'assets/images/touxiang.png',
                           ),
                         ),
                       ),
                       title: Text(
                           "王子异",
                           style: Text_Style().setTitle(Colors.white)
                       ),
                       trailing: GestureDetector(
                         child: Icon(

                           Icons.settings,
                           color: Colors.white,
                           size: 30,

                         ),
                         onTap: ()=>Navigator.push(context, MaterialPageRoute(builder: (_){
                           return Setting();
                         })).then((value) {
                           setState(() {

                           });
                         }),
                       ),
                       subtitle: Text(
                         "我就是我，不一样的烟火",
                         style: TextStyle(color: Colors.white),
                       ),
                     ) ,onTap:()=> Navigator.push(context, MaterialPageRoute(builder: (_){
                       return PersonalInformation();
                     })))
                      ,

                      Expanded(
                          child: Container(
                            child: GridView.builder(
                              gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                                //横轴元素个数
                                  crossAxisCount: 4,
                                  //纵轴间距
                                  mainAxisSpacing: 0.0,
                                  //横轴间距
                                  crossAxisSpacing: 0.0,
                                  //子组件宽高长度比例
                                  childAspectRatio: 1.0),
                              itemBuilder: (BuildContext context, int index) {
                                return Column(
                                  children: <Widget>[
                                    Text(
                                      myListNumber[index],
                                      style: TextStyle(fontSize: 18,color: Colors.white),
                                    ),
                                    Text(
                                      myList[index],
                                      style: TextStyle(fontSize: 18,color: Colors.white),
                                    ),
                                  ],
                                );
                              },
                              itemCount: myList.length,
                            ),
                          )),
                      SizedBox(
                        height: 10,
                      ),
                    ],
                  )),
            ),
          ),



          Positioned(child: Container(
            margin: EdgeInsets.all(10),
            child: Column(
              children: <Widget>[

                Container(
                  alignment: Alignment.center,
                  height: 70
                  ,
                  //渐变色
                  decoration: BoxDecoration(
                    gradient: LinearGradient(//渐变位置
                        begin: Alignment.topLeft,//渐变开始位置
                        end: Alignment.bottomRight,//渐变结束位置
                        stops: [0.0,2], //[渐变起始点, 渐变结束点]
                        colors: [Color(0xffFFE1FF), //渐变颜色[始点颜色, 结束颜色]
                          Color(0xffFDF5E6)
                        ]
                    ),
                    //设置圆角
                    borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10)),

                  ),

                  child: Row(children: <Widget>[
                    Expanded(child: ListTile(
                      title: Text("会员中心",style: TextStyle(fontSize: 18,fontWeight: FontWeight.w900),),
                      subtitle: Text("热享品牌9折",style: TextStyle(fontSize: 16,color: Colors.red)),
                      trailing: Icon(Icons.label),
                    ) ),
                    //垂直分割线
                    VerticalDivider(
                      color: Colors.grey,
                      width: 1,//左右间距
                      indent: 10,//距离顶部距离
                      endIndent: 10,//距离底部距离
                      thickness: 0.2,//分割线粗细
                    ),
                    Expanded(child: ListTile(
                      title: Text("积分",style: TextStyle(fontSize: 18,fontWeight: FontWeight.w900),),
                      subtitle: Text("做任务赚积分",style: TextStyle(fontSize: 16,color: Colors.red)),
                      trailing: Icon(Icons.label),
                    ) ),

                  ],),
                ),

                Container(
                  alignment: Alignment.center,
                  height: 70,
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.only(bottomLeft: Radius.circular(10),bottomRight: Radius.circular(10))
                  ),


                  child: Row(children: <Widget>[
                    Expanded(child: ListTile(
                      title: Text("红包省钱卡",style: TextStyle(fontSize: 18,fontWeight: FontWeight.w900),),
                      subtitle: Text("最高领99元红包",style: TextStyle(fontSize: 16,color: Colors.red)),
                      trailing: Icon(Icons.label),
                    ) ),
                    VerticalDivider(
                      color: Colors.grey,
                      width: 1,//左右间距
                      indent: 10,//距离顶部距离
                      endIndent: 10,//距离底部距离
                      thickness: 0.2,//分割线粗细
                    ),
                    Expanded(child: ListTile(
                      title: Text("红包签到",style: TextStyle(fontSize: 18,fontWeight: FontWeight.w900),),
                      subtitle: Text("每天都能领红包",style: TextStyle(fontSize: 16,color: Colors.red)),
                      trailing: Icon(Icons.label),
                    ) ),

                  ],),
                ),
                SizedBox(
                  height: 15,
                ),
                //我的订单
                Container(
                  alignment: Alignment.center,
                  height: 120,
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(10))
                  ),

                  child: Column(children: <Widget>[
                    ListTile(
                        title: Text('我的订单',style: TextStyle(fontWeight: FontWeight.w900,fontSize: 18)),
                        trailing: Chip(

                          label: Text("查看全部订单",style: TextStyle(color: Colors.grey),),
                          labelPadding: EdgeInsets.all(0),//标签文字的间距
                          deleteIcon: Icon(Icons.keyboard_arrow_right),
                          onDeleted: (){},
                          elevation: 0,
                          shadowColor: Colors.transparent,
                          backgroundColor: Colors.transparent,
                        )
                    ),
                    Expanded(child:  GridView.builder(
                      physics: NeverScrollableScrollPhysics(),
                      gridDelegate:
                      SliverGridDelegateWithFixedCrossAxisCount(



                          childAspectRatio: 1,
                          mainAxisSpacing: 1,
                          crossAxisSpacing: 1,
                          crossAxisCount: 5
                      ),
                      itemBuilder: (BuildContext context,int index){
                        return
                          Column(
                            children: <Widget>[
                              Icon(orderIcon[index],color: Colors.deepOrangeAccent,),
                              SizedBox(height: 5,),
                              Text(ordertitle[index],style: TextStyle(fontSize: 15),),
                            ],
                          );
                      },
                      itemCount: ordertitle.length,
                    ))

                  ],),),
                SizedBox(
                  height: 15,
                ),
                //我的钱包
                Container(
                  alignment: Alignment.center,
                  height: 120,
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(10))
                  ),

                  child: Column(children: <Widget>[
                    ListTile(
                        title: Text('我的钱包',style: TextStyle(fontWeight: FontWeight.w900,fontSize: 18)),
                        trailing: Chip(

                          label: Text("查看我的钱包",style: TextStyle(color: Colors.grey),),
                          labelPadding: EdgeInsets.all(0),//标签文字的间距
                          deleteIcon: Icon(Icons.keyboard_arrow_right),
                          onDeleted: (){},
                          elevation: 0,
                          shadowColor: Colors.transparent,
                          backgroundColor: Colors.transparent,
                        )
                    ),
                    Expanded(child:  GridView.builder(
                      physics: NeverScrollableScrollPhysics(),
                      gridDelegate:
                      SliverGridDelegateWithFixedCrossAxisCount(
                          childAspectRatio: 1,
                          mainAxisSpacing: 1,
                          crossAxisSpacing: 1,
                          crossAxisCount: 5
                      ),
                      itemBuilder: (BuildContext context,int index){
                        return
                          Column(
                            children: <Widget>[
                              Text(walletMoneys[index],style: TextStyle(fontSize: 15,fontWeight: FontWeight.w900),),
                              SizedBox(height: 5,),
                              Text(walletTitles[index],style: TextStyle(fontSize: 15),),
                            ],
                          );
                      },
                      itemCount: walletTitles.length,
                    ))

                  ],),),
              ],

            ),
          ),top: 130,bottom: 0,left: 10,right: 10,
          )
        ],

      ),
    ));
  }
}


